<?php

include_once dirname(dirname(__FILE__)) . '/include/common.php';
$core = new core();
$html = '';

$list_category = $core->getListCategory();
if ($list_category) {
    foreach ($list_category as $category) {
        $html.='<tr>
                    <td class = "center" >' . $category->category_name . '</td>
                    <td class="center">' . $category->category_parent . '</td>
                    <td class="center" >
                        <a class="btn btn-info btn_edit_category" href="javascript:void(0)" rel="' . $category->category_id . '">
                        <i class="icon-edit icon-white"></i>  
                         Edit                                            
                        </a>
                        <a href="#" class="btn btn-danger btn_delete_category" rel="' . $category->category_id . '">
                            <i class="icon-trash icon-white"></i> 
                            Delete
                        </a>
                    </td>
                </tr>';
       
    }
}
$list_category_parent= $core->getCategoryByParentId(0);
$category_list='<select class ="category_parent"><option value="0" selected>Chọn parent category</option>';
if ($list_category_parent) {
    foreach ($list_category_parent as $category) {     
        $category_list.=' <option value="'. $category->category_id.'">'.$category->category_name.'</option>';
    }
}
$category_list.='</select>';
echo json_encode(array('type' => 0, 'html' => $html,'category_list'=>$category_list));
die;
?>
